package com.huxi.lang.validation.predicate;

import java.util.Objects;

public class Eq implements VPredicate {

	private Object v;

	Eq(Object v) {
		this.v = v;
	}

	@Override
	public boolean test(Object t, boolean valueIfNull, boolean valueIfIllegalType) {
		return t != null ? t.equals(v) : valueIfNull;
	}

	@Override
	public boolean test(Object t) {
		return Objects.equals(t, v);
	}

	@Override
	public VPredicate negate() {
		return new Ne(v);
	}

	@Override
	public String toString() {
		return "Eq";
	}

}
